#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H

#include <iostream>
#include <vector>
#include "SDL/SDL.h"
#include "SDL_image/SDL_image.h"
#include "SDL_mixer/SDL_mixer.h"

#include "Bulit.h"

#ifdef WIN32
//Include needed libs.
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#pragma comment(lib, "SDL_image.lib")
#pragma comment(lib, "SDL_mixer.lib")
#endif

#define MAXIMUM_FRAME_RATE 60
#define MINIMUM_FRAME_RATE 15
#define UPDATE_INTERVAL (1.0 / MAXIMUM_FRAME_RATE)
#define MAX_CYCLES_PER_FRAME (MAXIMUM_FRAME_RATE / MINIMUM_FRAME_RATE)

/**
 * Main class for the game engine framework.
 */
class Environment
{
public:
	/**
	 * Default constructor.
	 */
	Environment();
	
	/**
	 * Default destructor.
	 */
	virtual ~Environment();
	
	/**
	 * Initiates the SDL graphics and creates a window.
	 *
	 * @param screenWidth - intvalue setting windows width.
	 * @param screenHight - int value setting window hight.
	 * @param windowsTitle - string value setting the window title.
	 * @return int kontaining error code.
	 */
	virtual void init(int screenWidth, int screenHeight,
					  const char *windowTitle);
	
	/**
	 * Quits the SDL.
	 */
	virtual void end();
	
private:
	//Representents the screen canvas.
	SDL_Surface* mScreen;
	
	//Resourceholder.
	SDL_Surface* mImage;
	
	/**
	 * Game loop that controls the games functions
	 */
	void gameLoop();
	
	/**
	 * Updates screen content.
	 * @param posX lcation of ship
	 * @param posX lcation of ship
	 */
	void gameAction(int posX, int posY);
	
	/**
	 * Loads a image.
	 * 
	 * @param string containing name of file.
	 * @returns an SDL_Surface containing image.
	 */
	SDL_Surface* loadImage(std::string imgName);
	
	/**
	 * Loads resources used by game.
	 */
	void loadScene();
	
	/**
	 * Update background.
	 */
	void Environment::updateBackground();
	
	/**
	 * Shoots a bullit.
	 */
	void Environment::shoot();
};

#endif //ENVIRONMENT_H
